/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package di.server.context;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author Kilian Ito
 */
public class AppContext {
    
    private AppContext() {
    }
    
    protected static final String contextXML = "WEB-INF/applicationContext.xml";
    protected static ApplicationContext instance;
    
    public static void setApplicationContext(ApplicationContext ctx) {
        instance = ctx;
        Logger logger = Logger.getLogger(AppContext.class);
        logger.log(Level.TRACE, "Context loaded");
    }
    
    public static ApplicationContext getInstance() {
        return instance;
    }
    
    public static <T> T getBean(Class<T> clazz) {
        return getInstance().getBean(clazz);
    }
}
